package restructure.chapter06;

/**
 * @Description 函数对象取代函数
 * @Date 2021/9/19
 * @Created by Jonathan
 */
public class Account {

    /**
     * 原始版本
     */
    public int gamma(int inputVal, int quantity, int yearToDate) {
        int importantValue1 = (inputVal * quantity + delta());
        int importantValue2 = (inputVal * yearToDate + 100);
        if ((yearToDate - importantValue1) > 100) {
            importantValue2 -= 20;
        }
        int importantValue3 = importantValue2 * 7;
        // and so on
        return importantValue3 - 2 * importantValue1;
    }

    /**
     * 优化版本【函数对象取代函数】
     */
    public int gamma_(int inputVal, int quantity, int yearToDate) {
        return new Gamma(this, inputVal, quantity, yearToDate).compute();
    }

    public int delta() {
        return 0;
    }
}
